#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
inline int read()
{
    int x=0,f=1;
    char tmp;
    tmp=getchar();
    if(tmp<'0'||tmp>'9')
    {
        if(tmp=='-')
            f=-1;
    }
    else
    {
        x=tmp-'0';
    }
    tmp=getchar();
    while(tmp>='0'&&tmp<='9')
    {
        x*=10;
        x+=tmp-'0';
        tmp=getchar();
    }
    return f*x;
}
ll n,a[100005],T,ans,paintl[100005];
ll calc()
{
    //puts("calc");
    ll c=0,i=0,last0pos=-1,last1pos=-1;
    //int t[8]={1,1,0,1,1,0,1,0};
    //for(int i=0;i<n;i++)
    //{
    //    if(paintl[i]!=t[i]) return 0;
    //}
    for(int i=0;i<n;i++)
    {
        //cout<<i<<" "<<last0pos<<" "<<last1pos<<" "<<c<<" "<<endl;
        if(paintl[i]==0)
        {
            if(a[i]==a[last0pos]&&last0pos!=-1)
            {
                c+=a[i];
            }
            last0pos=i;
        }
        if(paintl[i]==1)
        {
            if(a[i]==a[last1pos]&&last1pos!=-1)
            {
                c+=a[i];
            }
            last1pos=i;
        }
    }
    return c;
}
ll paint(int pos)
{
    if(pos==n) return calc();
    ll maxc=0;
    paintl[pos]=0;
    maxc=max(paint(pos+1),maxc);
    //cout<<paintl[0]<<paintl[1]<<paintl[2]<<" "<<endl;
    paintl[pos]=1;
    maxc=max(paint(pos+1),maxc);
    //cout<<paintl[0]<<paintl[1]<<paintl[2]<<" "<<endl;
    return maxc;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    T=read();
    while(T--)
    {
        n=read();
        for(int i=0;i<n;i++)
        {
            a[i]=read();
        }
        ans=paint(0);
        printf("%lld\n",ans);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
